import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useUserStore = defineStore(
  'user',
  () => {
    let loginUser = ref({
      userName: '未登录',
      userRole: null,
    })

    function updateUser(data) {
      loginUser.value = data
    }

    function userLogout() {
      loginUser.value = {
        userName: '未登录',
        userRole: null,
      }
    }

    return {
      loginUser,
      updateUser,
      userLogout,
    }
  },
  {
    persist: true,
  },
)
